//
//  BaseTableViewController.swift
//  weibo
//
//  Created by 上官风雨 on 15/11/8.
//  Copyright © 2015年 上官风雨. All rights reserved.
//

import UIKit


class BaseTableViewController: UITableViewController,VisitorLoginViewDelegate {
    
    //用户访客模式
    var userLogin = UserAccountViewModel().userLogin
    
    var visitorLoginView :VisitorLoginView?
    
    override func loadView() {
        //如果用户没有登录就进入访客模式
        userLogin ? super.loadView() : loadVisitorView()
        
    }

    
  private  func loadVisitorView(){
        
        visitorLoginView = VisitorLoginView()
        
        view = visitorLoginView
    
    visitorLoginView?.visitorDelegate = self
    
    self.navigationItem.leftBarButtonItem  = UIBarButtonItem(title: "登录", style: .Plain, target: self, action: "visitorWillLogin")
    
    self.navigationItem.rightBarButtonItem  = UIBarButtonItem(title: "注册", style: .Plain, target: self, action: "visitorWillRegister")

    
    
    
    }
    
    func visitorWillLogin (){
        
        let vc = OauthViewController()
        
        let nav = UINavigationController(rootViewController: vc)
        
        presentViewController(nav, animated: true, completion: nil)
        
        }
    
    func visitorWillRegister(){
        
        print("register")
        
    }

    override func viewDidLoad() {
        super.viewDidLoad()
    }
}

